<?php


Route::get('login', 'LoginController@login')->name('admin.login');
Route::post('login', 'LoginController@login')->name('admin.login');
Route::get('logout', 'LoginController@logout');
Route::get('error', 'PublicController@showError')->name('admin.error');
Route::get('test', 'PublicController@test');
Route::group(['middleware' => ['auth:admin']], function ($router) {

//    $router->get('/', ['middleware'=>'permission:systems.index', 'uses'=>'AdminController@index']);

    $router->get('/', ['uses'=>'PublicController@index', 'middleware'=>['admin-menu']]);

    $router->get('/dash', function () {
        echo '你已经登陆';
    });

    $router->get('index', ['uses'=>'PublicController@index', 'middleware'=>['admin-menu']]);

    $router->get('main', 'PublicController@main');

    //  后台api接口中心   需要登陆,不需要指定权限
    $router->match(['get', 'post'], '/api/index/{method}', ['uses'=>'ApiController@index']);

    //  开发者才拥有的权限
    Route::group(['middleware'=>['role:developer']], function ($router){
        //  后台菜单管理
        $router->get('/menu/{pid?}', ['uses'=>'MenuController@index']);
        $router->match(['get', 'post'], '/menu/edit/{pid?}/{id?}', ['uses'=>'MenuController@edit']);
        $router->match(['get', 'post'], '/menu/delete/{ids?}', ['uses'=>'MenuController@delete']);

        $router->get('/config', ['uses'=>'ConfigController@index']);//
        $router->match(['get', 'post'], '/config/edit/{id?}', ['uses'=>'ConfigController@edit', ]);
        $router->match(['get', 'post'], '/config/delete/{ids?}', ['uses'=>'ConfigController@delete', ]);
    });


    /**
     * 节点授权 而非角色授权
     */

    //  管理员中心
    $router->get('/admin_user', ['middleware'=>['permission:admin-users-list'], 'uses'=>'AdminUserController@index']);//
    $router->match(['get', 'post'], '/admin_user/edit/{id?}', ['middleware'=>['permission:admin-users-edit'], 'uses'=>'AdminUserController@edit', ]);
    $router->match(['get', 'post'], '/admin_user/delete/{ids?}', ['middleware'=>['permission:admin-users-delete'], 'uses'=>'AdminUserController@delete', ]);

    //  后台角色管理
    $router->get('/role/{pid?}', ['middleware'=>['permission:admin-roles-list'], 'uses'=>'RoleController@index', ]);
    $router->match(['get', 'post'], '/role/edit/{id?}', ['middleware'=>['permission:admin-roles-edit'], 'uses'=>'RoleController@edit', ]);
    $router->match(['get', 'post'], '/role/delete/{ids?}', ['middleware'=>['permission:admin-roles-delete'], 'uses'=>'RoleController@delete', ]);
    $router->match(['get', 'post'], '/role/permission/{role_id?}', ['middleware'=>['permission:admin-roles-permission'], 'uses'=>'RoleController@permission', ]);

    //  配置管理
    $router->match(['get', 'post'], '/config/setting', ['middleware'=>['permission:admin-configs-setting'], 'uses'=>'ConfigController@setting', ]);


    Route::group(['prefix' => 'portal', 'namespace' => 'Portal'], function ($router) {
        //  栏目管理
        $router->get('/category/{pid?}', ['middleware'=>['permission:admin-portal-category-list'], 'uses'=>'CategoryController@index']);//
        $router->match(['get', 'post'], '/category/edit/{id?}/{pid?}', ['middleware'=>['permission:admin-portal-category-edit'], 'uses'=>'CategoryController@edit', ]);
        $router->match(['get', 'post'], '/category/delete/{ids?}', ['middleware'=>['permission:admin-portal-category-delete'], 'uses'=>'CategoryController@delete', ]);

        //  资讯管理
        $router->get('/news', ['middleware'=>['permission:admin-portal-news-list'], 'uses'=>'DocumentNewsController@index']);//
        $router->match(['get', 'post'], '/news/edit/{id?}', ['middleware'=>['permission:admin-portal-news-edit'], 'uses'=>'DocumentNewsController@edit', ]);
        $router->match(['get', 'post'], '/news/delete/{ids?}', ['middleware'=>['permission:admin-portal-news-delete'], 'uses'=>'DocumentNewsController@delete', ]);
        $router->match(['get', 'post'], '/news/setStatus/{status}/{ids?}', ['middleware'=>['permission:admin-portal-news-set-status'], 'uses'=>'DocumentNewsController@setStatus', ]);

        //  图集管理
        $router->get('/photo', ['middleware'=>['permission:admin-portal-photo-list'], 'uses'=>'DocumentPhotoController@index']);//
        $router->match(['get', 'post'], '/photo/edit/{id?}', ['middleware'=>['permission:admin-portal-photo-edit'], 'uses'=>'DocumentPhotoController@edit', ]);
        $router->match(['get', 'post'], '/photo/delete/{ids?}', ['middleware'=>['permission:admin-portal-photo-delete'], 'uses'=>'DocumentPhotoController@delete', ]);
        $router->match(['get', 'post'], '/photo/setStatus/{status}/{ids?}', ['middleware'=>['permission:admin-portal-photo-set-status'], 'uses'=>'DocumentPhotoController@setStatus', ]);

        //  单网页
        $router->match(['get', 'post'], '/page/edit/{category_id?}', ['middleware'=>['permission:admin-portal-page-edit'], 'uses'=>'DocumentPageController@edit']);

        /*//  企业公示
        $router->get('/publicity', ['middleware'=>['permission:admin-portal-publicity-list'], 'uses'=>'DocumentPublicityController@index']);//
        $router->match(['get', 'post'], '/publicity/edit/{id?}', ['middleware'=>['permission:admin-portal-publicity-edit'], 'uses'=>'DocumentPublicityController@edit', ]);
        $router->match(['get', 'post'], '/publicity/delete/{ids?}', ['middleware'=>['permission:admin-portal-publicity-delete'], 'uses'=>'DocumentPublicityController@delete', ]);*/
    });

    Route::group(['prefix' => 'basic', 'namespace' => 'Basic'], function ($router) {

        //  友情链接管理
        $router->get('/link', ['middleware' => ['permission:admin-basic-link-list'], 'uses' => 'LinkController@index']);//
        $router->match(['get', 'post'], '/link/edit/{id?}', ['middleware' => ['permission:admin-basic-link-edit'], 'uses' => 'LinkController@edit',]);
        $router->match(['get', 'post'], '/link/delete/{ids?}', ['middleware' => ['permission:admin-basic-link-delete'], 'uses' => 'LinkController@delete',]);

        $router->get('/adv', ['middleware' => ['permission:admin-basic-adv-list'], 'uses' => 'AdvController@index']);//
        $router->match(['get', 'post'], '/adv/edit/{id?}', ['middleware' => ['permission:admin-basic-adv-edit'], 'uses' => 'AdvController@edit',]);
        $router->match(['get', 'post'], '/adv/delete/{ids?}', ['middleware' => ['permission:admin-basic-adv-delete'], 'uses' => 'AdvController@delete',]);

        $router->get('/adv/data/{adv_id}', ['middleware' => ['permission:admin-basic-adv-data-list'], 'uses' => 'AdvDataController@index']);//
        $router->match(['get', 'post'], '/adv/data/edit/{adv_id}/{id?}', ['middleware' => ['permission:admin-basic-adv-data-edit'], 'uses' => 'AdvDataController@edit',]);
        $router->match(['get', 'post'], '/adv/data/delete/{ids?}', ['middleware' => ['permission:admin-basic-adv-data-delete'], 'uses' => 'AdvDataController@delete',]);
    });

});


